package com.zxjbyte.yiyi.framework.common.domain;

import com.google.common.collect.Lists;

import java.util.List;

/**
 * @Author zhangxingjia
 * @Date 2023/4/20 11:18
 * @Version: 1.0
 */
public class Pair extends KvBean<String, String> {
    private static final long serialVersionUID = -4580802245555853611L;

    public Pair(String key, String value) {
        super(key, value);
    }

    public Pair() {
    }

    public static Pair of(String key, String value){
        return new Pair(key, value);
    }

    public static List<Pair> ofList(String... kvs){
        if(kvs == null || kvs.length == 0){
            return Lists.newArrayList();
        }
        List<Pair> list = Lists.newArrayList();
        for(int i = 0; i< kvs.length; i+=2){
            Pair pair = new Pair();
            pair.setKey(kvs[i]);
            if(i + 1 < kvs.length){
                pair.setValue(kvs[i + 1]);
            }
            list.add(pair);
        }
        return list;
    }


}
